<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2017/8/27
 * Time: 20:53
 */

namespace app\api\util;
require_once(ROOT_PATH . 'extend/alisms/TopSdk.php');

class SMSHelper
{
    public function send_msg($mobile, $vcode)
    {
        $c = new \TopClient;
        $c->appkey = config("ali_sms_appkey");
        $c->secretKey = config("ali_sms_secretKey");
        $req = new \AlibabaAliqinFcSmsNumSendRequest;
        $req->setExtend("123456");
        $req->setSmsType("normal");
        $req->setSmsFreeSignName("博媒易");
        $req->setSmsParam("{\"code\":\"".$vcode."\",\"product\":\"博媒易\"}");
        $req->setRecNum($mobile);
        $req->setSmsTemplateCode("SMS_60410122");
        $resp = $c->execute($req);
        return $resp;
    }

    /**
     * 告异常提醒：${time}您位于${address}所投放的${name} 出现${type}异常，目前处于${step}状态，如有疑问可联系客服${phone}。
     * @param  [type] $mobile [description]
     * @param  [type] $data   [description]
     * @return [type]         [description]
     */
    public function send_error_msg($mobile, $data)
    {
        $c = new \TopClient;
        $c->appkey = config("ali_sms_appkey");
        $c->secretKey = config("ali_sms_secretKey");
        $req = new \AlibabaAliqinFcSmsNumSendRequest;
        $req->setExtend("123456");
        $req->setSmsType("normal");
        $req->setSmsFreeSignName("博媒易");
        $req->setSmsParam("{\"time\":\"".$data['time']."\",\"address\":\"".$data['address']."\",\"name\":\"".$data['name']."\",\"type\":\"".$data['type']."\",\"step\":\"".$data['step']."\",\"phone\":\"0757-12345678\"}");
        $req->setRecNum($mobile);
        $req->setSmsTemplateCode("SMS_114160025");
        $resp = $c->execute($req);
        return $resp;
    }
}